﻿@{
    ViewBag.Title = "Index";
    //Layout = "~/Views/Shared/_Layout.cshtml";
}
 
 

<script>

    $(document).ready(function () {


        $(".spinner").hide();

        $("#send").click(function () {
           // alert(1);
            var emailAddress = $("#Email").val();
           
            EmailSubject = "Test Email";

            //url to post for email to be sent
            var postUrl = '@Url.Action("Notify","EIWST")';
            if (ValidateEmail(emailAddress)) {
                
                    //Call notify function to send notification
                SendEmail(emailAddress,  postUrl,  EmailSubject);
                 
            }
            else {
                // $('#email').after('<span class="error">Enter a valid email address.</span>');
                alert('Enter a valid email address!');
            }
        });
    });
    function SendEmail(emailAddress, postUrl, emailSubject) {
        //   alert(postUrl);
        $("#send").attr('disabled', 'disabled');
        $(".spinner").show();
        var user =
        {
            'emailAddress': emailAddress,
            'EmailSubject': emailSubject,
            __RequestVerificationToken: $("input[name=__RequestVerificationToken]").val()
        };

        $.post(
                postUrl,
                user,
                function (data) {
                    if (data === true) {
                        alert('An email has been sent.');
                        $(".spinner").hide();
                        $("#send").removeAttr('disabled');
                    }
                    else {
                        alert('Failed to send email.' + '\n' + data);
                        $(".spinner").hide();
                        $("#send").removeAttr('disabled');
                    }
                },
                'json'
            );
    }
</script>
@if (Model.IsManagerServiceTest)
    {
      <div id="header"><h1>Manager Service Test Results</h1></div>
     <div id="attention" style="margin:1em 1em 1em 0;">
        <div>
            <label style="font-weight:normal !important;">Data Service Test: </label>
            @*<img src="../../Content/images/button_check.png"  alt="" style="width:20px; vertical-align:text-top;"/>&nbsp;*@
            <label id="DataServiceTest" >@Model.STestStatus</label>
        </div> 
      
        <div style="font-weight:normal !important;">
             <p>@TempData["exc"]</p>
             <p>@TempData["exc1"]</p>
             <p>@TempData["exc2"]</p>
        </div>
    </div>
    }
else
    {
     <div id="header"><h1>Data Service and Database Test Results</h1></div>
   
<div id="content" style="padding: 20px 20px 80px;">
    <div id="attention" style="margin:1em 1em 1em 0;">
        <div>
            <label style="font-weight:normal !important;">Database Test: </label>
            
            @if (@Model.DBTestStatus=="Success")
                {
                  <img src="../../Content/images/button_check.png"  alt="" style="width:20px; vertical-align:text-top;"/>
                }
               @if (@Model.DBTestStatus=="Error")
                {
                  <img src="../../Content/images/error1.png"  alt="" style="width:20px; vertical-align:text-top;"/>
                } 
               
                  @if (@Model.DBTestStatus == "Incomplete")
                {
                  <img src="../../Content/images/sign_warning.png"  alt="" style="width:20px; vertical-align:text-top;"/>
                } 
                &nbsp; 
            <label id="DataBaseTest">@Model.DBTestStatus</label>
        </div> <br />
        <div>
            <label style="font-weight:normal !important;">Entity connection string Test: </label>
             @if (@Model.EFTestStatus == "Success")
                {
                  <img src="../../Content/images/button_check.png"  alt="" style="width:20px; vertical-align:text-top;"/>
                }
               @if (@Model.EFTestStatus == "Error")
                {
                  <img src="../../Content/images/error1.png"  alt="" style="width:20px; vertical-align:text-top;"/>
                } 
               
                  @if (@Model.EFTestStatus == "Incomplete")
                {
                  <img src="../../Content/images/sign_warning.png"  alt="" style="width:20px; vertical-align:text-top;"/>
                } 
                &nbsp;
            <label id="EFTest" >@Model.EFTestStatus</label>
        </div> <br />
        @*<div>
        <label style="font-weight:normal !important;">Manager Service Test: </label>
          @if (@Model.STestStatus == "Success")
            {
              <img src="../../Content/images/button_check.png"  alt="" style="width:20px; vertical-align:text-top;"/>
            }
           @if (@Model.STestStatus == "Error")
            {
              <img src="../../Content/images/error1.png"  alt="" style="width:20px; vertical-align:text-top;"/>
            }

              @if (@Model.STestStatus == "Incomplete")
            {
              <img src="../../Content/images/sign_warning.png"  alt="" style="width:20px; vertical-align:text-top;"/>
            }
            &nbsp;
        <label id="DataServiceTest" >@Model.STestStatus</label>
    </div> *@
      
       
        <div style="width:800px  ">
             
                <label style="font-weight:normal !important;">Email Test: </label>
                <input type="email" id="Email" name="Email" width="200" />
            
                <input type="button" id="send" value="Send" name="send" />
            <div class="spinner"  >
                <div class="bounce1"></div>
                <div class="bounce2"></div>
                <div class="bounce3"></div>

            </div>
            
            </div>

        <div style="font-weight:normal !important;">
            <p>@TempData["exc"]</p>
            <p>@TempData["exc1"]</p>
            <p>@TempData["exc2"]</p>
        </div>
    </div>

</div>
    }